package com.zhangzy.qm.filter;
import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class SecurityFilter implements Filter {

	public void destroy() {
		
	}

	public void doFilter(ServletRequest servletRequest,
			ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
//		HttpServletRequest request = (HttpServletRequest) servletRequest;
//		HttpServletResponse response = (HttpServletResponse) servletResponse;
//		HttpSession session = ((HttpServletRequest) request).getSession();		
//		String userName  = (String) session.getAttribute("userName");
//		String path = request.getContextPath();
//		String uri = request.getRequestURI();
//		if (uri.contains(path)) {
//			uri = uri.substring(path.length(), uri.length());
//		}
//		if(userName != null && !"".equals(userName)){
//			chain.doFilter(servletRequest, servletResponse);
//		}else{
//			response.sendRedirect(path+"/toLogin.action");
//		}
	}

	public void init(FilterConfig arg0) throws ServletException {
		
	}

}
